home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Moscow ML 1.42 / src / test / test2.sml < prev    next >
Encoding:
Text File  |  1997-08-18  |  453 b   |  27 lines  |  [TEXT/R*ch]

  1. fun fact 0 = 1
  2.   | fact n = n * fact(n-1);
  3.  
  4. fact 4;
  5.  
  6. fun append2 ([], ys) = ys
  7.   | append2 (x::xs, ys) = x :: append2 (xs,ys);
  8.  
  9. append2( [1,2,3], [4,5,6] );
  10.  
  11. fun append [] ys = ys
  12.   | append (x :: xs) ys = x :: append xs ys;
  13.  
  14. append [1,2,3] [4,5,6];
  15.  
  16. fun reverse xs =
  17.   let fun loop [] ys = ys
  18.         | loop (x::xs) ys = loop xs (x::ys)
  19.   in loop xs [] end;
  20.  
  21. reverse [1,2,3,4];
  22. reverse [true,false];
  23.  
  24. val op @ = append2;
  25. infixr 5 @;
  26. [1,2,3] @ [4,5,6];
  27.